package com.leet.code.lcof;

public class Code17 {
    public static void main(String[] args) {
        print(7);
    }

    public int[] printNumbers(int n) {
        int max = 0;

        for (int i = 1; i <= n; i++) {
            max = 10 * max + 9;
        }

        int[] res = new int[max];

        for (int i = res.length; i > 0; i--) {
            res[i - 1] = i;
        }

        return res;
    }


    public static void print(int n) {
        int[] w = new int[n];

        StringBuilder sb;

        boolean j = false;
        while (w[n - 1] != 0 || !j) {

            sb = new StringBuilder();
            w[0] = w[0] + 1;

            if (w[0] == 10) {
                w[0] = 0;
                j = true;
            } else {
                j = false;
            }
            sb.append(w[0]);
            for (int i = 1; i < n; i++) {
                if (!j) {
                    sb.insert(0, w[i]);
                    continue;
                }
                w[i] = w[i] + 1;
                if (w[i] == 10) {
                    w[i] = 0;
                    j = true;
                } else {
                    j = false;
                }
                sb.insert(0, w[i]);
            }
            System.out.println(sb.toString());
        }
    }



}
